<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="_patrimonio.xhtml">
	<ui:define name="corpo">

		<div id="conteudo">

			<h:form id="form">

				<h2>
					<h:outputText value="EDITAR ITEM"/>
				</h2>
				<hr />

				<p:messages id="msg" />
				
				<div align="center">
				<p:fieldset legend="Pesquisar">
								
				<h:outputLink value="javascript:void(0)" onclick="dlgItem.show();">
					<h:outputLabel value="Pesquisar" rendered="#{empty itemBean.item.id}"/>
					<h:outputLabel value="Descrição: " rendered="#{not empty itemBean.item.id}"/>
				</h:outputLink>
				
				<h:outputLink value="javascript:void(0)" onclick="dlgItem.show();">
				<h:graphicImage value="resources/img/lupa3.png" style="width: 40px;" onclick="dlgItem.show();" rendered="#{empty itemBean.item.id}" />
					<h:outputText id="mate" value="#{itemBean.item.material.nome}" onclick="dlgItem.show();" style="text-align: center; float: center; font-weight:bold;" rendered="#{not empty itemBean.item.id}" />
				</h:outputLink>
				
				</p:fieldset>
				</div>
				
				<p:fieldset>
				
				<h:outputLabel value="Descrição: " for="desc" style="color: white; font-weight:bold;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<p:inputText id="desc" value="#{itemBean.item.material.nome}" style="width: 400px;" /><br /><br />
				
				<h:outputLabel value="Marca: " for="marc" style="color: white; font-weight:bold;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;
				<p:inputText id="marc" value="#{itemBean.item.marca}" style="width: 150px;" /><br /><br />
				
				<h:outputLabel value="Valor Unitário: " for="valor" style="color: white; font-weight:bold;" rendered="#{empty patrimonioBean.patrimonio.id}" />
					<p:inputText id="valor" value="#{itemBean.item.valor_unit}">
						<f:convertNumber pattern="#0.00" />
					</p:inputText>	
				<br /><br />
				
				<h:outputLabel value="Quantidade: " for="qtd" style="color: white; font-weight:bold;" rendered="#{empty patrimonioBean.patrimonio.id}" />&nbsp;&nbsp;
				<p:inputText id="qtd" value="#{itemBean.item.quantidade}" style="width: 50px;" />
				<br /><br />

				<p:commandButton id="grava" value="GRAVAR" action="#{itemBean.grava}" ajax="false" image="ui-icon-disk" rendered="#{not empty itemBean.item.id}">
					<f:ajax render="@all" />
				</p:commandButton>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
				
				<p:commandButton id="cancel" value="CANCELAR EDIÇÃO" action="formAlterItem.xhtml"
						rendered="#{not empty itemBean.item.id}" ajax="false" icon="ui-icon-arrowreturnthick-1-w">
						<f:ajax render="@all" />
					</p:commandButton>
				<p />
				
				</p:fieldset>						

			</h:form>
			
			<p:dialog header="Itens Cadastrado" widgetVar="dlgItem" model="true" width="700" showEffect="hide">
					<h:form id="form1">

						<p:outputPanel id="itens">
							<p:dataTable value="#{itemBean.itens}" var="item" paginator="true"
								rows="10" emptyMessage="Não Encontrado">

								<p:column filterBy="#{item.material.nome}" filterMatchMode="contains"
									headerText="Descrição">
									<h:commandLink value="#{item.material.nome}" onclick="dlgItem.hide()"
										id="nome">
										<f:setPropertyActionListener
											target="#{itemBean.item}" value="#{item}" />
									</h:commandLink>
								</p:column>
								
								<p:column headerText="Tipo">
									<h:outputText value="#{item.material.tipo}" />
								</p:column>
								
								<p:column headerText="Nota Fiscal" filterBy="#{item.nota.numero}" filterMatchMode="contains">
									<h:outputText value="#{item.nota.numero}" />
								</p:column>
									
							</p:dataTable>
						</p:outputPanel>

					</h:form>
				</p:dialog>
								
		</div>


	</ui:define>
</ui:composition>
</html>